<%@page import="com.icss.th.db.pojo.PageInfo"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.icss.th.fulltext.pojo.SearchResult"%>
<%
	String spendTime = (String)request.getAttribute("spendTime");
	PageInfo pageInfo = (PageInfo)request.getAttribute("pageInfo");
	List<SearchResult> results = (List<SearchResult>)request.getAttribute("list");
	String id = (String)request.getAttribute("id");
	String name = (String)request.getAttribute("name");
	String context = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<title>题海</title>
<meta charset="UTF-8">
<link href="includes/css/style.css" rel="stylesheet" type="text/css">
<link href="includes/css/jquery-ui.min.css" rel="stylesheet" type="text/css">
<link href="includes/css/PagerView.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id=wrapper>
		<input type="hidden" name="pnum" id="pnum" value="">
		<input type="hidden" name="id" id="id" value="<%=id%>">
	    <div id=content1>
	        <div id=u  class="top-bg">
	            <div id=user>
	                <span style="float:left; padding-left:20px; padding-top:2px;"><img src="includes/images/title.png" width="71" height="34"></span>
	                <span style="float:left; padding-left:40px; padding-top:8px;"><a href="<%=context%>/"><img src="includes/images/home.png" width="25" height="23"></a></span>
            		<span style="float:left; padding-left:20px; padding-top:8px;font-size:14px;font-weight:bold;color:#444;line-height:26px;font-family:arial"><%=name%></span>
	                <div id=userMenu>
		                <a href="#">登录</a>&nbsp;<font color="#f68d00" size="2">|</font>&nbsp;
		                <a href="#">快速入口</a>&nbsp;<font color="#f68d00">|</font>&nbsp;
		                <a href="#">合作接口</a>
	                </div>
	            </div>
	        </div>
	    </div>

	    <div id="list">
			<ul>
	            <li>找到约<%=pageInfo.getRecordCount() %>条结果 （用时<%=spendTime%>秒）</li>
	        </ul>
	        <%
	        if (results != null && !results.isEmpty()){
	        	for (SearchResult r : results){
	        %>
	        <ul>
	            <li><A style="font-family:arial" href="<%=context%>/question?id=<%=r.getId()%>" class="list-title"><%=r.getTitle()%></A></li>
	            <li><A style="font-family:arial" href="#" style="color:#090; line-height:20px;"><%=r.getSourceName()%></A></li>
	            <li style="font-family:arial"><%=r.getContent()%></li>
	        </ul>
	        <%
	        	}
	        }
	        %>
	        
	        <div id="pager" style="height:30px; margin-bottom:20px; text-align:left;">
	        </div>
	        <ul style="height:30px; margin-bottom:1px; text-align:left;">
	            <li><A href="#" onclick="AddFavorite()">加入收藏夹</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A href="#">关于我们</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A href="#">加入我们</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A href="#">支持与捐赠</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A href="#">开放接口</A></li>
	            <li>©2013&nbsp;Tihai.org&nbsp;北京题海科技有限公司&nbsp;<A href="#" >使用必读</A>&nbsp;<a href="#" target="_blank">冀ICP备08007478号</a></li>
	        </ul>
	    </div>
</div>
<script src="includes/js/jquery-1.10.0.min.js" type="text/javascript"></script>
<script src="includes/js/jquery-ui.min.js" type="text/javascript"></script>
<script src="includes/js/PagerView.js" type="text/javascript"></script>
<script type="text/javascript">
	
	$(document).ready(function() {
		var pager = new PagerView('pager');
		pager.itemCount = <%=pageInfo.getRecordCount() %>;
		pager.size = <%=pageInfo.getCountPerPage() %>;
		pager.index = <%=pageInfo.getPageNum() %>
		pager.render();
		pager.onclick = function(index){
			$('#pnum').val(index);
			_submit();
		};
	});
	
	function _submit(){
		var path = '<%=context%>/paper?';
		path += 'id=' + $("#id").val();
		path += '&pnum=' + $("#pnum").val();
		location.href = path;
	}
	
	function AddFavorite(){
		var sURL = window.location;
		var sTitle = document.title;
	    try{
	        window.external.addFavorite(sURL, sTitle);
	    }catch (e){
	        try{
	            window.sidebar.addPanel(sTitle, sURL, "");
	        }catch (e){
	            alert("加入收藏失败，请使用Ctrl+D进行添加");
	        }
	    }
	}
</script>
</body>
</html>
